using UseCaseManager.BO;

namespace UseCaseManager.Test.BO
{
    public class TestUtilsUseCase
    {
        /// <summary>
        /// Creates a new saved UseCase with a random value assigned to every property
        /// </summary>
        public static UseCase CreateSavedUseCase()
        {
            return CreateSavedUseCase(null);
        }        
        /// <summary>
        /// Creates a new saved UseCase with a random value assigned to every property
        /// </summary>
        public static UseCase CreateSavedUseCase(Drop drop)
        {
            UseCase useCase = CreateUnsavedValidUseCase(drop);
            useCase.Save();
            return useCase;
        }

        /// <summary>
        /// Creates a new unsaved UseCase with a random value assigned to every property
        /// </summary>
        public static UseCase CreateUnsavedValidUseCase()
        {
            return CreateUnsavedValidUseCase(null);
        }
        /// <summary>
        /// Creates a new unsaved UseCase with a random value assigned to every property
        /// </summary>
        public static UseCase CreateUnsavedValidUseCase(Drop drop)
        {
            return CreateUnsavedValidUseCase(drop, TestUtils.GetRandomInt(0, 50));
        }
	    
        /// <summary>
        /// Creates a new unsaved UseCase where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static UseCase CreateUnsavedDefaultUseCase()
        {
            UseCase useCase = new UseCase();
            return useCase;
        }

        public static UseCase CreateUnsavedValidUseCase(Drop drop, int? pointsAssigned)
        {
            UseCase useCase = new UseCase();
            useCase.PackageID = TestUtilsPackage.CreateSavedPackage().PackageID;
            useCase.UseCaseNumber = TestUtils.GetRandomInt();
            useCase.UseCaseName = TestUtils.GetRandomString();
            useCase.Actors = TestUtils.GetRandomString();
            useCase.Description = TestUtils.GetRandomString();
            useCase.Assumptions = TestUtils.GetRandomString();
            useCase.PreConditions = TestUtils.GetRandomString();
            useCase.PostConditions = TestUtils.GetRandomString();
            useCase.Trigger = TestUtils.GetRandomString();
            useCase.UserLastUpdated = TestUtils.GetRandomDate();
            useCase.DateTimeLastUpdated = TestUtils.GetRandomDate();
            useCase.PointsAssigned = pointsAssigned;
            if (drop != null) useCase.DropID = drop.DropID;
            useCase.SetBaseline();
            return useCase;
        }
        /// <summary>
        /// Creates a new saved UseCase with a random value assigned to every property
        /// </summary>
        public static UseCase CreateSavedUseCase(Drop drop, int? pointsAssigned)
        {
            UseCase useCase = CreateUnsavedValidUseCase(drop, pointsAssigned);
            useCase.Save();
            return useCase;
        }
    }
}